package tk.leafotto.sign2.dao;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MySqliteOpenHelper extends SQLiteOpenHelper {

    public MySqliteOpenHelper(Context context) {
        super(context, "sign.db", null, 2);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table player(_id integer primary key autoincrement, name varchar(20), pinyin varchar(50), deltag integer DEFAULT '0', head varchar(50))");
        db.execSQL("create table sign(_id integer primary key autoincrement, _date date, uid integer)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        if(oldVersion == 1 && newVersion == 2){
            db.execSQL("alter table player add head varchar(50)");
        }
    }
}
